import api from '../index'

export default {
  // 登录
  login: (data: {
    username: string
    password: string
    code: string
    uuid: string
  }) => api.post('/login', data, {}),
  // 图形验证码
  captchaImage: () => api.get('/captchaImage', {
  }),
  // 校验图形验证码
  validateCaptcha: (data: {
    captcha: string
    uuid: string
  }) => api.get(`/validateCaptcha`, {
    params: {
      captcha: data.captcha,
      uuid: data.uuid,
    },
  }),
  // 忘记密码验证码
  sendForgetPwdSms: (data: {
    phone: string
    uuid: string
    captcha: string
  }) => api.get(`/sendForgetPwdSms`, {
    params: {
      captcha: data.captcha,
      uuid: data.uuid,
      phone: data.phone,
    },
  }),
  // 发送验证码
  sendSms: (data: {
    phone: string
    uuid: string
    captcha: string
  }) => api.get(`/sendSms`, {
    params: {
      captcha: data.captcha,
      uuid: data.uuid,
      phone: data.phone,
    },
  }),
  // 忘记密码
  forgetPwd: (data: {
    phone: string
    smsCode: string
    password: string
  }) => api.post(`/forgetPwd`, data, {
  }),
  // 扫码登录
  scanLoginByCode: (data: {
    code: string
  }) => api.get(`/wx/open/scanLoginByCode`, {
    params: {
      code: data.code,
    },
  }),
  // 直接发送验证码
  sendSmsNoCaptcha: (data: {
    phone: string
  }) => api.get(`/sendSmsNoCaptcha`, {
    params: {
      phone: data.phone,
    },
  }),
  // 登录绑定手机号
  loginBindPhone: (data: {
    unionid: string
    phone: string
    smsCode: string
  }) => api.post(`/wx/open/loginBindPhone`, data, {
  }),
  // 退出登录
  logout: () => api.get(`/logout`, {
  }),
  // 注册
  register: (data: {
    username: string
    password: string
    smsCode: string
  }) => api.post(`/register`, data, {
  }),
  // 注册验证码
  sendRegisterSms: (data: {
    phone: string | undefined
    uuid: string
    captcha: string | undefined
  }) => api.get(`/sendRegisterSms`, {
    params: {
      captcha: data.captcha,
      uuid: data.uuid,
      phone: data.phone,
    },
  }),
  // 获取权限
  permission: () => api.get('/getPermissions', {
  }),

  // 修改密码
  passwordEdit: (data: {
    password: string
    newPassword: string
  }) => api.post('user/password/edit', data, {
  }),

  // 获取偏好设置
  preferences: () => api.get('user/preferences', {
  }),

  // 修改偏好设置
  preferencesEdit: (preferences: string) => api.post('user/preferences/edit', {
    preferences,
  }, {
  }),

  // 获取标签栏固定标签页数据
  tabbar: () => api.get('user/tabbar', {
  }),

  // 修改标签栏固定标签页数据
  tabbarEdit: (tabbar: string) => api.post('user/tabbar/edit', {
    tabbar,
  }, {
  }),

  // 获取收藏夹
  favorites: () => api.get('user/favorites', {
  }),

  // 修改收藏夹
  favoritesEdit: (favorites: string) => api.post('user/favorites/edit', {
    favorites,
  }, {
  }),
}
